using GraphQLDemo.Domain.CompanyProjects;

namespace GraphQLDemo.Infrastructure.Repositories
{
    public class CompanyProjectRepository : ICompanyProjectRepository
    {
        public async Task<ILookup<Guid, CompanyProject>> GetProjectsByCompanyIdAsync(IEnumerable<Guid> companyIds, CancellationToken cancellationToken)
        {
            Console.WriteLine("Execute CompanyProjectRepository-GetProjectsByCompanyIdAsync");
            var companyProjects = new List<CompanyProject>()
            {
                new CompanyProject()
                {
                    Id = Guid.NewGuid(),
                    CompanyId = companyIds.First(),
                    Name = "name1"
                },
                new CompanyProject()
                {
                    Id = Guid.NewGuid(),
                    CompanyId = companyIds.First(),
                    Name = "name2"
                },
                new CompanyProject()
                {
                    Id = Guid.NewGuid(),
                    Name = "name3",
                    CompanyId = companyIds.Last(),
                },
                new CompanyProject()
                {
                    Id = Guid.NewGuid(),
                    Name = "name4",
                    CompanyId = companyIds.Last(),
                }
            };

            return await Task.FromResult(companyProjects.ToLookup(x => x.CompanyId));
        }
    }
}
